const path = require("path");
const { name } = require('./package');

function resolve(dir) {
  return path.join(__dirname, dir);
}

const dev = process.env.NODE_ENV === "development";
module.exports = {
  publicPath: dev ? `/` : "/",
  outputDir: "dist",
  // assetsDir: "static",
  filenameHashing: true,
  devServer: {
    hot: true,
    disableHostCheck: true,
    port:8080,
    overlay: {
      warnings: false,
      errors: true,
    },
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
    proxy: {
      "/nodeApi": {
        target:'http://127.0.0.1:8888', // local
        pathRewrite: {
          "^/nodeApi": "",
        },
      },
    },
  },
  // 自定义webpack配置
  configureWebpack: {
    resolve: {
      alias: {
        "@": resolve("src"),
      },
    },
    // output: {
    //   // production 模式和热更新的同时不能用chunkhash
    //   filename: '[name].[hash].js',
    //   // 把子应用打包成 umd 库格式
    //   library: `${name}-[name]`,
    //   libraryTarget: "umd",
    //   jsonpFunction: `webpackJsonp_${name}`,
    // },
  },
};
